package com.yanqu.road.server.cmd.activity.carptrip;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.CarpTripProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.carptrip.CarpTripModule;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_CARP_TRIP_PVP_FIGHT_FROM_CROSS, desc = "PVP跨服返回")
public class CarpTripPVPFightFromCrossCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {

        CarpTripProto.CarpTripPVPFightRespMsg respMsg = CarpTripProto.CarpTripPVPFightRespMsg.parseFrom(packet.getBytes());

        ret = player.getModule(CarpTripModule.class).fightResult(respMsg);
    }

    @Override
    public void sendData(GamePlayer player) {
        if(ret != 0){
            player.sendPacket(Protocol.U_CARP_TRIP_PVP_FIGHT, CarpTripProto.CarpTripPVPFightRespMsg.newBuilder().setRet(ret));
        }
    }
}
